package com.spera.shopoa.util;

import java.io.File;

import com.spring.security.core.util.ApplicationUtils;

public class tools {
	public static String getFileType(String fileUri) {
		File file = new File(fileUri);
		String fineName = file.getName();
		if(fineName.indexOf(".")==-1){
			return "";
		}else{
			String fileType = fineName.substring(fineName.lastIndexOf(".") + 1,
					fineName.length());
			return fileType;
		}
	}
	
	public static boolean checkFileType(String fileType,String... allowType){
		boolean isAllow = false;
		if(ApplicationUtils.isNotNull(fileType)&&ApplicationUtils.isNotNull(allowType)){
			for(String type:allowType){
				if(fileType.equalsIgnoreCase(type)){
					isAllow = true;
				}
			}
		} 
		return isAllow;
	}
}
